package crazy.memory;

import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;

public class PhantomReferenceTest
{
	public static void main(String[] args) throws Exception
	{
		String str = new String("crazy java");
		ReferenceQueue<String> rq = new ReferenceQueue<String>();
		PhantomReference<String> pr = new PhantomReference<String>(str, rq);
		str = null;
		System.out.println(pr.get());
		System.gc();
		System.runFinalization();
		System.out.println(rq.poll() == pr);
		
 	}
}
